package cn.tedu.cn.tedutestsonpackage;

import cn.tedu.pojo.TestCar;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author SWJ
 * @create 2021-07-14 9:51
 * 得到JSON数据：
 * * {"id":718,
 * * "name":"保时捷",
 * * "type":"Cayman T",
 * * "color":"红色",
 * * "price":641000.0}
 */
@RestController
//@RestController=@Controller+@ResponseBody
@RequestMapping("abc")
/**abc网页类文件*/

public class controller {
    @RequestMapping("get1")
    public TestCar get() {
        TestCar c = new TestCar();
        /*在对汽车类型进行实例化*/
        c.setColor("red");
        c.setId(718);
        c.setType("poreshch");
        c.setPrice(6233.2);
        //double类型的
        return c;
    }

    @RequestMapping("add")
    //框架解析http://localhost:8090/car/add?id=1
    public void add(Integer id) {
        System.out.println(id);
    }

    @RequestMapping("add2")
    //框架解析"http://localhost:8090/abc/add?id=1&name=张三"
    public void add2(Integer id, String name) {
        System.out.println(id + name);
    }

    @RequestMapping("add3")
    //"http://localhost:8090/abc/add3?id=1&name=张三&color=red"
    public void add3(TestCar c ) {
        System.out.println(c);
    }

}

